
<?php
require_once '../include.php';

$objectid=$_REQUEST['objectid']?$_REQUEST['objectid']:null;
// var_dump($objectid);

$PG = new pgsql("gis24.jlu3s.com", "23456", "ccly", "sde", "GIScontest2024");  
$PG->connect(); 
if(!$PG){  
    $db_error = "无法连接到PostGreSQL数据库！";  
    echo $db_error;   
}else{

    $q1 = "select * from sde.sight where objectid='{$objectid}'";
    // var_dump($q1);
    $result = $PG->query($q1);
    // var_dump($result);
    $row = @pg_fetch_array($result);
    // var_dump($row);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>*^_^* 修改景点</title>
<style>
    tr{
        line-height: 50px;
    }
    .pic_path_input {
        width:700px;
        height:25px; 
    }
</style>
</head>

<body>
	<div style="padding: 15px 15px;" class="details">
		<h2>修改景点信息</h2>
		<form action="doEditsight.php" method="post" id="reg" name="reg" onsubmit="return checksubmit()">

			<div>
				<input type="hidden" name="objectid" value="<?php echo $row['objectid']; ?>"><!-- 隐藏域：ID -->
			</div>

			<table class="table" cellspacing="0" cellpadding="0">
            <tr>
                <td align="right"><span style="color:red;">*</span>名称：</td>
                <td><input type="text" name="name" value="<?php echo $row['name']; ?>"/></td>
            </tr>
            <tr>
                <td align="right"><span style="color:red;">*</span>市县区：</td>
                <td><input type="text" name="county" value="<?php echo $row['county']; ?>"/></td>
            </tr>
            <tr>
                <td align="right"><span style="color:red;">*</span>区号：</td>
                <td><input type="text" name="areacode" value="<?php echo $row['areacode']; ?>"/></td>
            </tr>
            <tr>
                <td align="right">电话：</td>
                <td><input type="text" name="phone" value="<?php echo $row['phone']; ?>"/></td>
            </tr>
            <tr>
                <td width="15%" align="right"><span style="color:red;">*</span>描述(限500字)：</td>
                <td><textarea type="text" cols="100" rows="1" name="address" style="border: 1px solid #999;"><?php echo $row['address']; ?></textarea></td>
            </tr>
            <tr>
                <td align="right"><span style="color:red;">*</span>类型：</td>
                <td><input type="text" name="type" value="<?php echo $row['type']; ?>"/></td>
            </tr>       
            <tr align="left">
                <td colspan="2" >
                    <input type="submit" value="提  交 修 改"  class="btn" style="cursor: pointer; height: 30px; width: 100px" />&nbsp;&nbsp;
                    <input type="button" value="取  消 修 改" class="btn" onclick="Cancel()" style="cursor: pointer; height: 20px; width: 80px" />
                </td>
            </tr>            
        </table>

		</form>
	</div>
	
<script>
    function Cancel(){
        window.location="sightList.php";
    }
</script>
<script language="javascript">
    function checksubmit(){
        if(document.reg.name.value==""){
            alert("名称不能为空！");
            document.reg.name.focus();
            return false;
        }
        else if(document.reg.province.value==""){
            alert("省份不能为空！");
            document.reg.province.focus();
            return false;
        }        
        else if(document.reg.description.value==""){
            alert("描述不能为空！");
            document.reg.description.focus();
            return false;
        }  
        return true;  
    }
</script>
</body>
</html>
